<?php
namespace app\admin\validate;
use think\Validate;
use think\Db;
class Games extends Validate
{

    // 验证规则
    protected $rule = [
        'gameid'            =>'checkId',
        'infoid'            =>'require|number|checkInfoid',
        'goodsid'				=>'require|checkGid',
        'name'				=>'require|min:1|max:150'
    ];
    //错误信息
    protected $message  = [
        'infoid.require'                            => '资讯编号',
        'infoid.number'                             => '资讯编号为数字',
        'infoid.checkInfoid'                        => '资讯编号无效',
        'name.require'                              => '名称必填',
        'name.min'                            		=> '最少一个字符',
        'name.max'                             		=> '最多30个汉字',
        'goodsid.require'                           	=> '请选择一个商品',
        'goodsid.checkGid'                           	=> '请选择一个商品..'
    ];


    /**
     * 检查是否有商品规格参加活动，若有则不能编辑商品
     * @param $value
     * @return bool
     */
    protected function checkId($value){
        return true;
    }
	
	protected function checkInfoid($value){
		if($value<=0){
			return false;
		}
		return true;
	}
	
	protected function checkGid($value){
		if($value==''){
			return false;
		}
		return true;
	}
}